<?php

class Admin_Form_Users_InsertUser extends Zend_Form {

    /**
     * Form for register user
     * @author Nguyen Manh Hung
     */
    public function init() {
        $this->setAction('')->
                setMethod('post');

        $gender = $this->createElement('select', 'gender');

        $gender->setLabel('Giới Tính')->
                setMultiOptions(array(
                    '1' => 'Nam',
                    '0' => 'Nữ'
                ))->
                setRequired(true)->addValidator('NotEmpty', true);

        $group = $this->createElement('select', 'group');

        $group->setLabel('Phân Quyền')->setRequired(true)->addValidator('NotEmpty', true);

        $username = $this->createElement('text', 'username');

        $username->setLabel('Tên Đăng Nhập:')->
                setRequired(true)->
                addFilter('StripTags')->
                addFilter('StringTrim')->
                addFilter('StringToLower')->
                setAttrib('size', 30)->
                setAttrib('maxlength', 100)->
                addValidator('NotEmpty')->
                addValidator('stringLength', false, array(
                    6,
                    20
                ));

        $password = $this->createElement('password', 'password');

        $password->setLabel('Mật Khẩu')->
                setRequired(true)->
                addFilter('StripTags')->
                addFilter('StringTrim')->
                setAttrib('size', 30)->
                setAttrib('maxlength', 100)->
                addValidator('stringLength', false, array(
                    6,
                    20
                ))->
                addValidator('NotEmpty');

        $email = $this->createElement('text', 'email');

        $email->setLabel('Email:')->
                setRequired(true)->
                addFilter('StripTags')->
                addFilter('StringTrim')->
                addFilter('StringToLower')->
                setAttrib('size', 50)->
                setAttrib('maxlength', 100)->
                addValidator('EmailAddress');

        $status = $this->createElement('checkbox', 'active', array(
            'label' => 'Sử Dụng:',
            'checkedValue' => 1,
            'uncheckedValue' => 0
                ));

        $status->setValue(1);

        $submit = $this->createElement('submit', 'submit');

        $submit->setAttrib('id', 'submit_register');

        $submit->setLabel('Submit');

        $submit->setAttrib('class', 'formbutton');

        $submit->setDecorators(array(
            'ViewHelper',
            array(
                'HtmlTag',
                array(
                    'tag' => 'hb'
                ),
                array(
                    'Label',
                    array(
                        'tag' => ''
                    )
                )
            )
        ));

        $reset = $this->createElement('reset', 'reset', array(
            'label' => 'Làm Lại'
                ));

        $reset->setDecorators(array(
            'ViewHelper',
            array(
                'HtmlTag',
                array(
                    'tag' => 'hb'
                ),
                array(
                    'Label',
                    array(
                        'tag' => ''
                    )
                )
            )
        ));

        $reset->setAttrib('class', 'formbutton');

        $cancel = $this->createElement('button', 'back', array(
            'label' => 'Quay Lại'
                ));

        $cancel->setDecorators(array(
            'ViewHelper',
            array(
                'HtmlTag',
                array(
                    'tag' => 'hb'
                ),
                array(
                    'Label',
                    array(
                        'tag' => ''
                    )
                )
            )
        ));

        $cancel->setAttrib('class', 'formbutton');

        $this->addElement($gender)->
                addElement($email)->
                addElement($username)->
                addElement($password)->
                addElement($group)->
                addElement($status)->
                addElement($submit)->
                addElement($reset)->
                addElement($cancel);
    }

}